package com.angel.web.sys;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import com.angel.core.util.HttpRequest;
import com.angel.core.util.JsonUtil;
import com.angel.core.util.MD5Util;

public class Test {
	public static void main(String[] args) throws Exception {
		String appKey = "1127c69f80a7d3c0af0e9192bb0b1d08";
		String appSecret = "b4ba27b6c861";
		String nonce = "12345";
		String curTime = String.valueOf((new Date()).getTime() / 1000L);
		String checkSum = MD5Util.getCheckSum(appSecret, nonce, curTime);// 参考
																			// 计算CheckSum的java代码

		Map<String, String> header = new HashMap<String, String>();
		header.put("AppKey", appKey);
		header.put("Nonce", nonce);
		header.put("CurTime", curTime);
		header.put("CheckSum", checkSum);
		header.put("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
		List<NameValuePair> nvps = new ArrayList<NameValuePair>();
		nvps.add(new BasicNameValuePair("accid", "ceshi5"));
		nvps.add(new BasicNameValuePair("accidd", "ceshi3"));

		String url = "https://api.netease.im/nimserver/user/create.action";
		String post = HttpRequest.toPost(url, header, nvps);
//		String json = "{\"code\":200,\"info\":{\"token\":\"d2651cedca633e40beb8732440ab8fdd\",\"accid\":\"ceshi3\",\"name\":\"\"}}";
//		String json_e = "[{\"desc\":\"already register\",\"code\":414}]";
//		Map<String, String> jsonStringToList = JsonUtil.jsonStringToMap(json);
		System.err.println(post);
	}
}
